//
//  BIZRapidAnswerCell.m
//  biz
//
//  Created by 小龙 on 2017/3/21.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "BIZRapidAnswerCell.h"
#import "BIZAnswerModel.h"

@interface BIZRapidAnswerCell ()


@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *contentLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *addQuestionContentLabel;
@property (weak, nonatomic) IBOutlet UILabel *addAnswerContentLabel;

@property (weak, nonatomic) IBOutlet UILabel *posiationLabel;
@property (weak, nonatomic) IBOutlet UILabel *companyLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addAnswerViewLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addQuetionViewLayout;
@property (weak, nonatomic) IBOutlet UIView *addQuestionView;

@property (weak, nonatomic) IBOutlet UIView *addAnswerView;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addQustionHeadHeightLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addQuestionTopLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addQuestionBottomLayout;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addAnswerHeadHeightLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addAnswerTopLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addAnswerBottomLayout;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *adoptBtnBottomLayout;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addQuestionViewHeightLayout;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *addAnswerViewHeightLayout;
@property (weak, nonatomic) IBOutlet UILabel *addQuestionTitleLabel;

@property (weak, nonatomic) IBOutlet UILabel *addAnswerTitleLabel;

@property (weak, nonatomic) IBOutlet UILabel *adoptStatusLabel;

@end

@implementation BIZRapidAnswerCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}


- (void)setAnswerModel:(BIZAnswerModel *)answerModel
{
    _answerModel = answerModel;
    
    self.nameLabel.text = answerModel.name;
    self.dateLabel.text = [NSDate stringFromTimestamp:answerModel.date];
    self.contentLabel.text = answerModel.content;
    self.addQuestionContentLabel.text = answerModel.askedContent;
    self.addAnswerContentLabel.text = answerModel.askedAnswer;
    self.posiationLabel.text = answerModel.position;
    self.companyLabel.text = answerModel.fname;
    [SDWebImageTool imageView:self.headImageView
                    imageName:answerModel.headImg placeHolder:@"default-head" showProgress:YES];
    
    if (answerModel.stage < 2) {
        self.adoptBtnBottomLayout.constant = 5;
        self.addQuestionTitleLabel.text = @"";
        self.addQustionHeadHeightLayout.constant = 0;
        self.addQuestionTopLayout.constant = 0;
        self.addQuestionBottomLayout.constant = 0;
        
        
        self.addAnswerTitleLabel.text = @"";
        self.addAnswerHeadHeightLayout.constant = 0;
        self.addAnswerTopLayout.constant = 0;
        self.addAnswerBottomLayout.constant = 0;
    }
    else if (answerModel.stage == 2 ) {
        
        self.addQuestionTitleLabel.text = @"用户追问";
        self.addQustionHeadHeightLayout.constant = 30;
        self.addQuestionTopLayout.constant = 14;
        self.addQuestionBottomLayout.constant = 14;
        
        self.addAnswerTitleLabel.text = @"";
        self.addAnswerHeadHeightLayout.constant = 0;
        self.addAnswerTopLayout.constant = 0;
        self.addAnswerBottomLayout.constant = 0;
        
        
    }
    else {
        self.addQuestionTitleLabel.text = @"用户追问";
        self.addQustionHeadHeightLayout.constant = 30;
        self.addQuestionTopLayout.constant = 14;
        self.addQuestionBottomLayout.constant = 14;
        
        self.addAnswerTitleLabel.text = @"咨询师回答";
        self.addAnswerHeadHeightLayout.constant = 30;
        self.addAnswerTopLayout.constant = 14;
        self.addAnswerBottomLayout.constant = 14;
    }
    
   
    if([answerModel.status isEqualToString:@"1"]){
        self.adoptStatusLabel.hidden = NO;
    }else {
        self.adoptStatusLabel.hidden = YES;
    }
}


- (IBAction)adoptBtnClick:(UIButton *)sender {
    if (self.delegate &&[self.delegate respondsToSelector:@selector(consultAnswerCellAdoptBtnClick:)]) {
        [self.delegate consultAnswerCellAdoptBtnClick:self];
    }
}

- (IBAction)addQuestionBtnClick:(UIButton *)sender {
    if (self.delegate &&[self.delegate respondsToSelector:@selector(consultAnswerCellAddQuestionBtnClick:)]) {
        [self.delegate consultAnswerCellAddQuestionBtnClick:self];
    }
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
}
@end
